package com.itheima.staticdemo;

/**
 * @Author 王加鑫
 * @Date 2021/5/4 18:01
 * @Version 1.0
 * static详解
 */
public class Demo1 {
    public static void main(String[] args) {
        /*
        school被static关键字修饰属于静态变量
        静态变量随着类的加载而加载,跟随着类
        在方法区中被赋默认值
        静态变量可以被整个类共享

         */
        System.out.println(Person.school);
        Person p1 = new Person();
        p1.name = "张三";
        p1.age = 20;
        Person.school = "家里蹲大学";
        System.out.println(p1.name + " " + p1.age + " " + p1.school);

        Person p2 = new Person();
        System.out.println(p2.name + " " + p2.age + " " + p2.school);


    }
}
